﻿//<TunynetCopyright>
//--------------------------------------------------------------
//<copyright>青岛拓宇网络科技有限公司 2005-2008</copyright>
//<version>V0.5</verion>
//<createdate>2008-2-21</createdate>
//<author>mazq</author>
//<email>mazq@tunynet.com</email>
//<log date="2008-2-21">创建</log>
//--------------------------------------------------------------
//</TunynetCopyright>


using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Collections;
using System.Drawing;
using System.Workflow.ComponentModel;
using System.Workflow.ComponentModel.Design;
using System.Workflow.ComponentModel.Compiler;
using System.Workflow.ComponentModel.Serialization;
using System.Workflow.Runtime;
using System.Workflow.Activities;
using System.Workflow.Activities.Rules;
using System.Collections.Generic;
using ChinaCustoms.Qingdao.Workflow.Supports;
using System.Drawing.Design;
using ChinaCustoms.Qingdao.Workflow.Activities.Chooser;

namespace ChinaCustoms.Qingdao.Workflow.Activities
{
    /// <summary>
    /// 海关工作流通用活动
    /// </summary>
    [PersistOnClose]
    [ToolboxBitmap(typeof(CommonActivity), "Resources.gear.png")]
    [Designer(typeof(CommonActivityDesigner), typeof(IDesigner))]
    public partial class CommonActivity : ChinaCustomsBaseActivity
    {
        /// <summary>
        /// 构造函数
        /// </summary>
        public CommonActivity()
        {
            InitializeComponent();
        }

        #region Properties


        public static DependencyProperty CodeNameProperty = System.Workflow.ComponentModel.DependencyProperty.Register("CodeName", typeof(string), typeof(CommonActivity), new PropertyMetadata(DependencyPropertyOptions.Metadata));

        /// <summary>
        /// 活动编码
        /// </summary>
        /// <remarks>(必须填写,并且要唯一,只允许在设计期间修改)</remarks>
        [Description("活动编码(必须填写,并且要唯一,只允许在设计期间修改)")]
        [Category("活动")]
        [Browsable(true)]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
        public override string CodeName
        {
            get
            {
                string codeName = string.Empty;
                try
                {
                    codeName = (string)base.GetValue(CommonActivity.CodeNameProperty);
                }
                catch { }

                return codeName;
            }
            set { base.SetValue(CommonActivity.CodeNameProperty, value); }
        }

        public static DependencyProperty UrlOfWorkItemProperty = System.Workflow.ComponentModel.DependencyProperty.Register("UrlOfWorkItem", typeof(string), typeof(CommonActivity), new PropertyMetadata(DependencyPropertyOptions.Metadata));

        /// <summary>
        /// 执行或浏览该活动的工作项时调用的URL
        /// </summary>
        [Description("执行或浏览该活动的工作项时调用的URL")]
        [Category("活动")]
        [Browsable(true)]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
        public override string UrlOfWorkItem
        {
            get { return base.GetValue(CommonActivity.UrlOfWorkItemProperty) as string; }
            set { base.SetValue(CommonActivity.UrlOfWorkItemProperty, value); }
        }

        public static DependencyProperty AllowRedesignateExecutorProperty = System.Workflow.ComponentModel.DependencyProperty.Register("AllowRedesignateExecutor", typeof(bool), typeof(CommonActivity), new PropertyMetadata(DependencyPropertyOptions.Metadata));

        /// <summary>
        /// 是否允许运行时由前一个活动执行人指定该活动执行人
        /// </summary>
        [Description("是否允许运行时由前一个活动执行人指定该活动执行人")]
        [Category("常用设置")]
        [Browsable(true)]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
        public bool AllowRedesignateExecutor
        {
            get
            {
                bool allowRedesignateExecutor = true;
                try
                {
                    allowRedesignateExecutor = (bool)base.GetValue(CommonActivity.AllowRedesignateExecutorProperty);
                }
                catch { }

                return allowRedesignateExecutor;
            }
            set { base.SetValue(CommonActivity.AllowRedesignateExecutorProperty, value); }
        }


        public static DependencyProperty AllowPostilProperty = System.Workflow.ComponentModel.DependencyProperty.Register("AllowPostil", typeof(bool), typeof(CommonActivity), new PropertyMetadata(DependencyPropertyOptions.Metadata));

        /// <summary>
        /// 是否允许填写审批意见
        /// </summary>
        [Description("是否允许填写审批意见")]
        [Category("常用设置")]
        [Browsable(true)]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
        public bool AllowPostil
        {
            get
            {
                bool allowPostil = true;
                try
                {
                    allowPostil = (bool)base.GetValue(CommonActivity.AllowPostilProperty);
                }
                catch { }

                return allowPostil;
            }
            set { base.SetValue(CommonActivity.AllowPostilProperty, value); }
        }

        public static DependencyProperty AllowFinalJudgmentProperty = System.Workflow.ComponentModel.DependencyProperty.Register("AllowFinalJudgment", typeof(bool), typeof(CommonActivity), new PropertyMetadata(DependencyPropertyOptions.Metadata));
        /// <summary>
        /// 是否允许办结
        /// </summary>
        [Description("是否允许办结")]
        [Category("常用设置")]
        [Browsable(true)]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
        public bool AllowFinalJudgment
        {
            get
            {
                bool allowFinalJudgment = true;
                try
                {
                    allowFinalJudgment = (bool)base.GetValue(CommonActivity.AllowFinalJudgmentProperty);
                }
                catch { }

                return allowFinalJudgment;
            }
            set { base.SetValue(CommonActivity.AllowFinalJudgmentProperty, value); }
        }


        public static DependencyProperty ActivityCodeNamesForJumpProperty = System.Workflow.ComponentModel.DependencyProperty.Register("ActivityCodeNamesForJump", typeof(string), typeof(CommonActivity), new PropertyMetadata(DependencyPropertyOptions.Metadata));
        /// <summary>
        /// 可跳转到的活动编码
        /// </summary>
        [Description("可跳转到的活动编码")]
        [Category("常用设置")]
        [Browsable(true)]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
        public string ActivityCodeNamesForJump
        {
            get
            {
                string activityCodeNamesForJump = string.Empty;
                try
                {
                    activityCodeNamesForJump = base.GetValue(CommonActivity.ActivityCodeNamesForJumpProperty) as string;
                }
                catch { }

                return activityCodeNamesForJump;
            }
            set { base.SetValue(CommonActivity.ActivityCodeNamesForJumpProperty, value); }
        }

        public static DependencyProperty AllowBackProperty = System.Workflow.ComponentModel.DependencyProperty.Register("AllowBack", typeof(bool), typeof(CommonActivity), new PropertyMetadata(DependencyPropertyOptions.Metadata));
        /// <summary>
        /// 是否允许回退到前一个活动
        /// </summary>
        [Description("是否允许回退到前一个活动")]
        [Category("常用设置")]
        [Browsable(true)]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
        public bool AllowBack
        {
            get
            {
                bool allowBack = true;
                try
                {
                    allowBack = (bool)base.GetValue(CommonActivity.AllowBackProperty);
                }
                catch { }

                return allowBack;
            }
            set { base.SetValue(CommonActivity.AllowBackProperty, value); }
        }

        public static DependencyProperty ActivityLevelProperty = System.Workflow.ComponentModel.DependencyProperty.Register("ActivityLevel", typeof(int), typeof(CommonActivity), new PropertyMetadata(DependencyPropertyOptions.Metadata));

        /// <summary>
        /// 活动级别
        /// </summary>
        /// <remarks>(必须填写,并且要唯一,活动之间要递加--这个规则有设计器来保证)</remarks>
        [Description("活动级别(必须填写,并且要唯一,活动之间要递加)")]
        [Category("常用设置")]
        [Browsable(false)]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
        public override int ActivityLevel
        {
            get
            {
                int activityLevel = 0;
                try
                {
                    activityLevel = (int)base.GetValue(CommonActivity.ActivityLevelProperty);
                }
                catch { }

                return activityLevel;
            }
            set { base.SetValue(CommonActivity.ActivityLevelProperty, value); }
        }

        public static DependencyProperty RequiredDepartmentIDsProperty = System.Workflow.ComponentModel.DependencyProperty.Register("RequiredDepartmentIDs", typeof(string), typeof(CommonActivity));

        /// <summary>
        /// 活动对应的直接部门
        /// </summary>
        /// <remarks>多个部门ID用逗号分割</remarks>
        [Description("活动对应的直接部门(多个部门ID用逗号分割)")]
        [Category("常用设置")]
        [Browsable(true)]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
        [Editor(typeof(ChooserForGeneralOrganization), typeof(UITypeEditor))]
        public string RequiredDepartmentIDs
        {
            get { return base.GetValue(CommonActivity.RequiredDepartmentIDsProperty) as string; }
            set { base.SetValue(CommonActivity.RequiredDepartmentIDsProperty, value); }
        }

        /// <summary>
        /// 活动对应的直接部门名称
        /// </summary>
        /// <remarks>多个部门名称用逗号分割</remarks>
        [Description("活动对应的直接部门名称(在使用属性RequiredDepartmentIDs时,系统自动指定)")]
        [Category("常用设置")]
        [Browsable(true)]
        [EditorBrowsable(EditorBrowsableState.Never)]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
        public string RequiredDepartmentNames
        {
            get { return requiredDepartmentNames; }
            set { requiredDepartmentNames = value; }
        }
        private string requiredDepartmentNames = string.Empty;


        public static DependencyProperty RequiredRelativeDepartmentProperty = System.Workflow.ComponentModel.DependencyProperty.Register("RequiredRelativeDepartment", typeof(RelativeDepartmentLevel), typeof(CommonActivity));

        /// <summary>
        /// 活动对应的相对部门
        /// </summary>
        /// <remarks>其分为以下几种:未设置(NotSet),相对所属部门(RelativeOneLevel),相对顶级部门(RelativeTopLevel)</remarks>
        [Description("活动对应的相对部门:未设置(NotSet),相对所属部门(RelativeOneLevel),相对顶级部门(RelativeTopLevel)")]
        [Category("常用设置")]
        [Browsable(true)]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
        public RelativeDepartmentLevel RequiredRelativeDepartment
        {
            get { return (RelativeDepartmentLevel)base.GetValue(CommonActivity.RequiredRelativeDepartmentProperty); }
            set { base.SetValue(CommonActivity.RequiredRelativeDepartmentProperty, value); }
        }

        public static DependencyProperty RequiredRolesProperty = System.Workflow.ComponentModel.DependencyProperty.Register("RequiredRoles", typeof(string), typeof(CommonActivity));
        /// <summary>
        /// 执行该活动的角色列表
        /// </summary>
        /// <remarks>多个角色名称之间用逗号分隔</remarks>
        [Description("执行该活动的角色列表(多个角色名称之间用逗号分隔)")]
        [Category("常用设置")]
        [Browsable(true)]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
        [Editor(typeof(ChooserForGeneralRole), typeof(UITypeEditor))]
        public string RequiredRoles
        {
            get { return base.GetValue(CommonActivity.RequiredRolesProperty) as string; }
            set { base.SetValue(CommonActivity.RequiredRolesProperty, value); }
        }

        public static DependencyProperty RequiredUserNamesProperty = System.Workflow.ComponentModel.DependencyProperty.Register("RequiredUserNames", typeof(string), typeof(CommonActivity));
        /// <summary>
        /// 执行该活动的用户名列表
        /// </summary>
        /// <remarks>多个用户名之间用逗号分隔</remarks>
        [Description("执行该活动的用户名列表(多个用户名之间用逗号分隔)")]
        [Category("常用设置")]
        [Browsable(true)]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
        [Editor(typeof(ChooserForGeneralUser), typeof(UITypeEditor))]
        public string RequiredUserNames
        {
            get { return base.GetValue(CommonActivity.RequiredUserNamesProperty) as string; }
            set { base.SetValue(CommonActivity.RequiredUserNamesProperty, value); }
        }

        #endregion

    }
}
